package com.jzo2o.foundations.controller.operation;


import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.service.IServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 区域服务表 区域服务接口
 * </p>
 *
 * @author dmr
 * @since 2024-10-27
 */
@Validated
@RestController("operationServeController")
@RequestMapping("/operation/serve")
@Api(tags = "运营端 - 区域服务相关接口")
public class ServeController {

    @Autowired
    private IServeService serveService;

    @GetMapping("/page")
    @ApiOperation("条件区域服务分页查询")
    public PageResult<ServeResDTO> queryServeByReginId(ServePageQueryReqDTO servePageQueryReqDTO) {

        return serveService.pageByReginIdQuery(servePageQueryReqDTO);
    }
    @PostMapping("/batch")
    @ApiOperation("区域服务新增服务")
    public void batchAdd(@RequestBody List<ServeUpsertReqDTO> serveUpsertReqDTOList) {
        serveService.saveBatch(serveUpsertReqDTOList);
    }


    @PutMapping("/{id}")
    @ApiOperation("区域服务修改服务价格")
    public void update(@PathVariable ("id") Long serveId,@RequestParam ("price") Double price) {
        serveService.update(serveId,price);
    }

    @PutMapping("onSale/{id}")
    @ApiOperation("区域服务设置上架状态")
    public void onSale(@PathVariable ("id") Long serveId) {
        serveService.onSale(serveId);
    }

    @PutMapping("offSale/{id}")
    @ApiOperation("区域服务设置下架状态")
    public void offSale(@PathVariable ("id") Long serveId) {
        serveService.offSale(serveId);
    }


    @DeleteMapping("/{id}")
    @ApiOperation("区域服务修改服务价格")
    public void delete(@PathVariable ("id") Long serveId) {
        serveService.delete(serveId);
    }


    @PutMapping("offHot/{id}")
    @ApiOperation("区域服务设置热门状态")
    public void offHot(@PathVariable ("id") Long serveId) {
        serveService.offHot(serveId);
    }

    @PutMapping("onHot/{id}")
    @ApiOperation("区域服务设置热门状态")
    public void onHot(@PathVariable ("id") Long serveId) {
        serveService.onHot(serveId);
    }

}
